#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> child_type;

int main() {
    int num, tmp;
    cin >> num;
    //num = (2 << (num-1));
    num = pow(2, num);
    cout << num;
    vector<child_type> child;
    for (int i = 0; i < num; ++i) {
        cin >> tmp;
        child.push_back(child_type(tmp, i+1));
    }
    //sort(child.begin(), child.end());
    queue<child_type> small_win;
    queue<child_type> big_win;
    for (int i = 0; i < child.size()/2; ++i) {
        if (child[2*i].first < child[2*i+1].first) {
            small_win.push(child[2*i+1]);
        } else {
            small_win.push(child[2*i]);
        }
    }
    child_type people1, people2;
    while (small_win.size()+big_win.size() != 1) {
        while (!small_win.empty() && (small_win.size()!=1)) {
            people1 = small_win.front();
            small_win.pop();
            people2 = small_win.front();
            small_win.pop();
            if (people1.first > people2.first) {
                big_win.push(people2);
            } else {
                big_win.push(people1);
                
            }
        }
        while (!big_win.empty() && (big_win.size() != 1)) {
            people1 = big_win.front();
            big_win.pop();
            people2 = big_win.front();
            big_win.pop();
            if (people1.first > people2.first) {
                small_win.push(people1);
            } else {
                small_win.push(people2);
                
            }
        }
    }
    if (small_win.empty()) {
        cout << big_win.front().second;
    } else {
        cout << small_win.front().second;
    }
    return 0;
}